package com.cneiu.ppms.web.action;


import com.cneiu.ppms.web.base.BaseController;
import com.cneiu.ppms.web.model.SubstationModel;
import com.cneiu.ppms.web.service.SubstationService;
import com.jfinal.plugin.activerecord.Page;

/**
 * 变电站Controller
 * @author zhaokf
 * @date 2013-04-19
 */
public class SubstationController extends BaseController
{
	/**
	 * 获取page limit得到变电站列表
	 */
	public void list(){
	
		Page<SubstationModel> Subs = SubstationService.list(this.getParams());
		if (null != Subs){
			renderGrid(Subs.getTotalRow(), Subs.getList());
		}else{
			renderAjax(false, SubstationService.getError());
		}
	}

	/**
	 * 添加变电站
	 */
	public void add(){
		try{
			boolean isNotError = true;
			if (!SubstationService.isAdd(this.getParams())){
				isNotError = false;
			}
			renderAjax(isNotError, SubstationService.getError());
		}
		catch (Exception e){
			e.printStackTrace();
		}

	}

	/**
	 * 编辑变电站
	 */
	public void edit(){
		try{
			boolean isNotError = true;
			if (SubstationService.isUpdate(this.getParams())){
				isNotError = false;
			}
			renderAjax(isNotError, SubstationService.getError());
		}
		catch (Exception e){
			e.printStackTrace();
		}
	}
	
	/**
	 * 删除变电站
	 */
	public void delete(){
		try{
			boolean isNotError = true;
			if (SubstationService.isDelete(this.getParams())){
				isNotError = false;
			}
			renderAjax(isNotError, SubstationService.getError());
		}
		catch (Exception e){
			e.printStackTrace();
		}
	}
}
